//
//  Customer.m
//  Hive
//
//  Created by 惠俊贝 on 15/9/2.
//  Copyright (c) 2015年 ZM. All rights reserved.
//

#import "Customer.h"

@implementation Customer
@synthesize MobilePhone = _MobilePhone;
@synthesize ContactPerson = _ContactPerson;
@synthesize Address = _Address;
@synthesize CustomerName = _CustomerName;
@synthesize CustomerType = _CustomerType;

- (id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super init];
    if ([aDecoder containsValueForKey: @"MobilePhone"])
    {
        _MobilePhone = [aDecoder decodeObjectForKey:@"MobilePhone"];
    }
    if ([aDecoder containsValueForKey: @"ContactPerson"])
    {
        _ContactPerson = [aDecoder decodeObjectForKey:@"ContactPerson"];
    }
    if ([aDecoder containsValueForKey: @"Address"])
    {
        _Address = [aDecoder decodeObjectForKey:@"Address"];
    }
    if ([aDecoder containsValueForKey: @"CustomerName"])
    {
        _CustomerName  = [aDecoder decodeObjectForKey:@"CustomerName"];
    }
    if ([aDecoder containsValueForKey: @"CustomerType"])
    {
        _CustomerType = [aDecoder decodeObjectForKey:@"CustomerType"];
    }
    return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder
{
    [aCoder encodeObject:_MobilePhone forKey:@"MobilePhone"];
    [aCoder encodeObject:_ContactPerson forKey:@"ContactPerson"];
    [aCoder encodeObject:_Address forKey:@"Address"];
    [aCoder encodeObject:_CustomerName forKey:@"CustomerName"];
    [aCoder encodeObject:_CustomerType forKey:@"CustomerType"];

    
}
+ (Customer *)creatCustomerWithDic:(NSDictionary *)dic {
    Customer *c = [[Customer alloc] init];
    c.MobilePhone = [dic objectForKey:@"MobilePhone"];
    c.ContactPerson = [dic objectForKey:@"ContactPerson"];
    c.Address = [dic objectForKey:@"Address"];
    c.CustomerName = [dic objectForKey:@"CustomerName"];
    c.CustomerType = [dic objectForKey:@"CustomerType"];
    return c;
}

@end
